from pathlib import Path
from trend.charts.scatter import KeywordDistributionGenerator

def generate_keyword_distribution():
    """生成核心词分布散点图"""
    
    # 示例数据 - 更真实的数据分布
    example_data = {
        "人工智能": {
            2019: 850, 
            2020: 1200, 
            2021: 2100, 
            2022: 1800, 
            2023: 2400
        },
        "深度学习": {
            2019: 600, 
            2020: 1500, 
            2021: 1300, 
            2022: 1900, 
            2023: 1600
        },
        "机器学习": {
            2019: 1200, 
            2020: 800, 
            2021: 1000, 
            2022: 1400, 
            2023: 900
        },
        "神经网络": {
            2019: 400, 
            2020: 900, 
            2021: 1100, 
            2022: 700, 
            2023: 800
        },
        "计算机视觉": {
            2019: 300, 
            2020: 600, 
            2021: 800, 
            2022: 1200, 
            2023: 1500
        }
    }
    
    # 创建输出目录
    output_dir = Path(__file__).parent.parent / 'output' / 'scatter'
    output_dir.mkdir(parents=True, exist_ok=True)
    
    # 创建生成器
    generator = KeywordDistributionGenerator()
    
    try:
        # 生成散点图
        save_path = output_dir / 'keyword_distribution_2023.html'
        result_path = generator.generate(
            data=example_data,
            save_path=str(save_path),
            title='AI领域核心词专利分布'
        )
        print(f"生成成功: {result_path}")
        
    except Exception as e:
        print(f"生成失败: {str(e)}")

if __name__ == "__main__":
    generate_keyword_distribution() 